package com.example.siyun.controller.permissionscontroller;

import com.example.siyun.pojo.PermissionsTable;
import com.example.siyun.pojo.VersionManager;
import com.example.siyun.service.permissionsservice.VersionManagerService;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:权限管理模块后台版本管理
 */
@Slf4j
@RestController
public class VersionManagerController {
    @Autowired
    private VersionManagerService versionManagerService;
    /**
     * 获取后台版本信息
     * @return 返回后台版本管理信息
     */
    @RequestMapping("/advanced/getversionmanager")
    public PageResult getVersionManager(int page, int limit,VersionManager versionManager) {
        log.info("获取后台版本信息");
        Map<String, Object> map = new HashMap<>();
        PageHelper.startPage(page, limit);
        List<VersionManager> list = versionManagerService.getVersion(versionManager);
        PageInfo<VersionManager> pageInfo = new PageInfo<>(list);
        PageResult pageResult=new PageResult();
        pageResult.setState(0);
        pageResult.setMessage("成功");
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setData(pageInfo.getList());
        log.info("获取后台版本信息成功");
        return pageResult;
    }
    /**
     * 获取后台版本信息通过id
     * @return 返回后台版本管理信息
     */
    @RequestMapping("/advanced/selectversionbyid")
    public PageResult selectPermissionsById(int id){
        log.info("获取后台版本信息通过id");
        VersionManager versionManager=versionManagerService.getVersionById(id);
        PageResult pageResult=new PageResult();
//        pageResult.setStatus(200);
        pageResult.setData(versionManager);
        log.info("获取后台版本信息通过id成功");
        return pageResult;
    }

}
